/*
 * @Author: dmyang
 * @Date:   2015-08-31 21:17:45
 * @Last Modified by:   dmyang
 * @Last Modified time: 2016-03-28 09:48:22
 */

'use strict'

import 'commonCss'


// 直接使用npm模块

require('../css/main.css')
require('../css/swiper.min.css')
require('../js/lib/swiper.min.js')

let report = require('./helpers/report')
let bar = require('./helpers/bar')
let url = require('./utils/url')
let $ajax = require('./helpers/ajax')
require('./utils/site')


let name = site.QueryString('type')


function handler () {
    site.getToken(render)
}

function render(){
    site.setNav(main)
    site.header()
    site._ajax({
        type:'GET',
        url: HTTP_SERVER + 'cms/api/websites/89060613317206016',
        data:{},
        success: function (res) {
            site.footer(res)
        }
    })
}
site.render = main
function main (pageId,proId) {
    let id = pageId?pageId:(site.id?site.id:site.QueryString('id'))
    let ind = site.getInd(id)
    let productId = proId?proId:site.QueryString('productId')
    site._ajax({
        type:"GET",
        url:HTTP_SERVER+"/file/api/files?prefix=company&marker=&limit=100&delimiter=",
        data:{},
        success:function(data){
            let r = data.items
            site._ajax({
                type:'GET',
                url:HTTP_SERVER+'cms/api/pages/'+productId,
                data:{},
                success: function(res){
                    let content = res.content
                    let name = res.name,navType = false
                    if(ind+1 == site.nav.length ){
                        navType = true
                    }
                    site.banner('108263273375256576',{navType:navType,type:site.type,company:r,id:id,nav:site.nav[ind],content:content,productId:productId})
                    site.menuHide()

                }
            })
        }
    })
}

document.addEventListener('visibilitychange', handler)
window.addEventListener('DOMContentLoaded', handler)
window.addEventListener('resize', handler)





